#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
    char buf[1024];
    int n = read(0, buf, sizeof(buf) - 1);
    buf[n] = '\0';
    write(1, buf, strlen(buf));

    close(1);
    n = printf("hello");
    fprintf(stderr, "%d\n", n);

    int fd = open("log.txt", O_WRONLY, 0664);
    if (fd < 0)
        perror("file open error");
    else
    {
        fprintf(stderr, "fd = %d\n", fd);
    }

    return 0;
}
